<template>
  <!-- 我的审批 -->
  <div id="myCheck">
    <div class="topBox">
      <div class="left">
        <img :src="require('/public/img/icon7.webp')" alt="" />
        <p class="name">我的审批</p>
      </div>
      <div class="right" @click="toList">
        <p class="lable">查看全部</p>
        <el-icon class="icon"><el-icon-arrow-right /></el-icon>
      </div>
    </div>
    <div class="list" v-if="list.length != 0">
      <div class="item" v-for="item in list" :key="item.id">
        <div class="top">
          <p class="title">{{ item.title }}</p>
          <el-tag
            type=""
            effect="dark"
            v-if="item.status == 0 && item.examineStatus == 0"
            >待审核</el-tag
          >
          <el-tag
            type="success"
            effect="dark"
            v-if="item.status == 1 || item.examineStatus == 1"
            >已通过</el-tag
          >
          <el-tag
            type="danger"
            effect="dark"
            v-if="item.status == 2 || item.examineStatus == 2"
            >未通过</el-tag
          >
          <!-- <el-tag type="warning" effect="dark" v-if="item.status == 3"
            >审核中</el-tag
          > -->
        </div>
        <div class="info">
          <div class="row">
            <el-icon>
              <el-icon-price-tag />
            </el-icon>
            <p class="value">类型：{{ item.streamTypeName }}</p>
          </div>
          <div class="row">
            <el-icon>
              <el-icon-user />
            </el-icon>
            <p class="value">申请人：{{ item.applyName }}</p>
          </div>
        </div>
        <div class="bottom">
          <p class="time">{{ item.createTime }}</p>
          <div class="showMore" @click="toDetail(item)">
            <p>查看更多</p>
            <el-icon class="icon"><el-icon-arrow-right /></el-icon>
          </div>
        </div>
      </div>
    </div>
    <el-empty :image-size="100" v-else class="empty"></el-empty>
  </div>
</template>
<script>
import { queryTypeByDic } from '@/utils/getData'
import { handleClick, initTableRow } from '@/utils/handleRouter'
export default {
  name: 'myCheck',
  data () {
    return {
      list: [],
      streamCode: [],//流程类型
    }
  },
  mounted () {
    this.getType()
  },
  methods: {
    async getType () {
      this.streamCode = await queryTypeByDic('streamCode')
      this.getList()
    },
    // 获取列表
    async getList () {
      let param = {
        limit: 4,
        page: 1,
      }
      let { data } = await this.$API.home.getMyExamineList.get(param)
      this.list = data
      console.log(data)
      this.list.forEach((item) => {
        item.applyName = item.applicantName || item.detail.username || item.detail.adminName
        this.streamCode.map((t_item) => {
          if (item.streamType == t_item.value) {
            item.streamTypeName = t_item.name
          }
        })
      })
      initTableRow(data)

    },
    // 跳转到我的审批列表页
    toList () {
      this.$router.push({
        path: '/home/myExamine'
      })
    },
    toDetail (row) {
      handleClick(row.streamType, row.detail.id)
    }
  }
}
</script>
<style lang="scss" scoped>
#myCheck {
  padding: 20px;
  background: #ffffff;
  border-radius: 8px;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  // min-height: 520px;
  .topBox {
    display: flex;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px #eee solid;
  }
  .left {
    display: flex;
    align-items: center;
    .name {
      margin-left: 10px;
      font-size: 16px;
    }
  }
  .right {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    .icon {
      margin-left: 5px;
      font-size: 16px;
    }
  }

  .list {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-top: 20px;
    // height: 300px;
    padding-bottom: 20px;
    // overflow-y: auto;
  }
  .item {
    flex-basis: calc((100% / 2) - 10px);
    // min-width: 400px;
    height: 200px;
    padding: 15px;
    margin-bottom: 20px;
    // margin-right: 20px;
    border: 1px solid #f1f1f1;
    border-radius: 4px;

    .title {
      width: 80%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .top {
      display: flex;
      justify-content: space-between;
      font-size: 16px;
      white-space: nowrap;
    }
    .info {
      display: flex;
      justify-content: space-between;
      margin: 30px 0;
      font-size: 14px;
      color: #666;
    }
    .row {
      display: flex;
      align-items: center;
      margin-bottom: 15px;
      .value {
        margin-left: 10px;
      }
    }
    .bottom {
      display: flex;
      justify-content: space-between;
      padding-top: 15px;
      border-top: 1px #eee solid;
      color: #999;
    }
    .showMore {
      display: flex;
      align-items: center;
      cursor: pointer;
    }

    &:hover {
      box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.1);
      .title {
        color: #366ef4;
      }
      .showMore {
        color: #366ef4;
      }
    }
  }
  .empty {
    height: 100%;
  }
}
</style>